package com.xiyou.luckdraw.web.controller;

import com.xiyou.luckdraw.api.dto.product.AddProductCategoryRequest;
import com.xiyou.luckdraw.api.dto.product.AddProductCategoryResponse;
import com.xiyou.luckdraw.api.service.IProductCategoryService;
import com.xiyou.luckdraw.common.constants.ResultCodeConstants;
import com.xiyou.luckdraw.common.result.ResponseData;
import com.xiyou.luckdraw.common.result.ResponseUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: ProductCategoryController
 * @Description:
 * @author: limingxing
 * @Date: 2019-10-16 20:13
 */
@RestController
@RequestMapping("/product")
@Api(value = "ProductCategoryController", tags = {"兑换商品接口"})
public class ProductCategoryController {

    @Autowired
    private IProductCategoryService productCategoryService;

    @PostMapping("/save")
    @ApiOperation("添加兑换商品")
    public ResponseData save(@RequestBody AddProductCategoryRequest request) {
        AddProductCategoryResponse response = productCategoryService.createProductCategory(request);
        if (response.getCode().equals(ResultCodeConstants.SUCCESS.getCode())) {
            return new ResponseUtils().setData("SUCCESS");
        }
        return new ResponseUtils().setData(response.getMsg());
    }


}
